
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class UmsPermissionServiceImpl implements UmsPermissionService  {

    @Resource
    private UmsPermissionMapper umsPermissionMapper;

    /**
     * 获取 UmsPermission 分页列表
     */
    @Transactional
    public IPage getUmsPermissionPagination( PaginationVo paginationVo, UmsPermissionQuery umsPermissionQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<UmsPermissionEntity> lqs = new LambdaQueryWrapper();
        umsPermissionMapper.selectPage(page, lqs);

        List<UmsPermissionEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 UmsPermission 所有数据
     *
    */
    @Transactional
    public List<UmsPermissionEntity> getUmsPermissionAllList( UmsPermissionQuery umsPermissionQuery ) throws Exception {

        LambdaQueryWrapper<UmsPermissionEntity> lqs = new LambdaQueryWrapper();
        List<UmsPermissionEntity> list = umsPermissionMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 UmsPermission 详情
    */
    @Transactional
    public UmsPermissionEntity getUmsPermissionDetail( Long id) throws Exception {

        UmsPermissionEntity umsPermission = umsPermissionMapper.selectById(id);
        return umsPermission;
    }


    /**
     * 新增 UmsPermission
     * */
    @Transactional
    public void addUmsPermission(UmsPermissionVo umsPermissionVo) throws Exception {

        UmsPermissionEntity umsPermission = new UmsPermissionEntity();
        ReflectionCopy.copyProperties( umsPermission, umsPermissionVo );
        umsPermissionMapper.insert(umsPermission);
        return;
    }


    /**
     * 更新 UmsPermission
     * */
    @Transactional
    public void updateUmsPermission( UmsPermissionVo umsPermissionVo) throws Exception {

        if( umsPermissionVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        UmsPermissionEntity umsPermission = new UmsPermissionEntity();
        ReflectionCopy.copyProperties( umsPermission, umsPermissionVo );
        umsPermissionMapper.updateById(umsPermission);
        return;
    }

    /**
     * 删除 UmsPermission
     * */
    @Transactional
    public void batchRemoveUmsPermission( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        umsPermissionMapper.deleteBatchIds(ids);
    }

}

      